<style>
    #scan_login {
        margin-top: -40px;
    }
</style>
<div id="scan_login"></div>
<script src="//g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js"></script>
<script>
    // 钉钉扫码登录
    var obj = DDLogin({
        id: "scan_login",
        goto: encodeURIComponent("{$dingUrl}"),
        style: "border:none;background-color:#FFFFFF;top:-35px;",
        width: "355",
        height: "300"
    });

    var hanndleMessage = function (event) {
        var origin = event.origin;
        console.log("origin", event.origin);
        if (origin == "https://login.dingtalk.com") { //判断是否来自ddLogin扫码事件。
            var loginTmpCode = event.data; //拿到loginTmpCode后就可以在这里构造跳转链接进行跳转了
            document.location.href = '{$dingUrl}&loginTmpCode=' + loginTmpCode;
        }
    };

    if (typeof window.addEventListener != 'undefined') {
        window.addEventListener('message', hanndleMessage, false);
    } else if (typeof window.attachEvent != 'undefined') {
        window.attachEvent('onmessage', hanndleMessage);
    }
</script>